Listing 18 illustrates how to use the MakeMediaTimeTable function to create a time table for media.
Listing 18 Creating a time table for media
OSErr theErr = noErr;
WindowPtr movieWindow = nil;
Movie theMovie = nil;
Track theTrack;
Media theMedia;
long trackCount,
trackIndex,
retDataRefSkew;
TimeValue startTime,
endTime,
timeIncrement;
short firstDataRefIndex,
lastDataRefIndex;
Handle offsets,
offsetsSet [32];
err = GetDisplayedMovie (&movieWindow, &theMovie);
firstDataRefIndex = -1;
lastDataRefIndex = -1;
trackCount = GetMovieTrackCount (theMovie);
for (trackIndex = 1; trackIndex <= trackCount; trackIndex++)
{
theTrack = GetMovieIndTrack (theMovie, trackIndex);
theMedia = GetTrackMedia (theTrack);
offsets = NewHandle (0);
offsetsSet [trackIndex - 1] = offsets;
startTime = GetTrackOffset (theTrack);
startTime = TrackTimeToMediaTime (startTime, theTrack);
endTime = GetTrackDuration (theTrack);
endTime = TrackTimeToMediaTime (endTime, theTrack);
timeIncrement = GetMediaTimeScale (theMedia);
err = MakeMediaTimeTable (theMedia, (long **) offsets,
startTime, endTime, timeIncrement, firstDataRefIndex,
lastDataRefIndex, &retDataRefSkew);
}
// dispose handles
for (trackIndex = 1; trackIndex <= trackCount; trackIndex++)
{
DisposeHandle (offsetsSet [trackIndex - 1]);
}
| Previous | Chapter Contents | Chapter Top | Next |